﻿$(document).ready(function () {
    //搜索
    $("#J_searchform").find("button.submit").hover(function () { $(this).addClass("button-hover") }, function () { $(this).removeClass("button-hover") });
    $("#J_searchform").find("input").each(function () {
        $(this).val($(this).attr("placeholder")).addClass("gray");
        $(this).focus(function () {
            if ($(this).val() == $(this).attr("placeholder")) {
                $(this).val("");
            };
            $(this).removeClass("gray");
        });
        $(this).blur(function () {
            if ($(this).val() == "") {
                $(this).val($(this).attr("placeholder")).addClass("gray"); return;
            };
            if ($(this).val() == $(this).attr("placeholder")) {
                $(this).addClass("gray");
            };
        });
    });
    $("#J_searchform").submit(function () {
        var input = $(this).find("input[name='keyword']");
        if (input.val() != "" && input.val() != input.attr("placeholder")) {
            window.open("http://iq.sdo.com/iq2/Question/SearchResult.aspx?Key=" + encodeURIComponent(input.val()));
        };
        return false;
    });
    $("#J_searchform").find("button[type='button']").click(function () {
        var input = $("#J_searchform").find("input[name='keyword']");
        if (input.val() != "" && input.val() != input.attr("placeholder")) {
            window.open("http://iq.sdo.com/iq2/Question/NewQuiz.aspx?Key=" + encodeURIComponent(input.val()));
        };
        return false;
    });

    //添加链接
    var go = jQuery.url.param("go");
    var q = jQuery.url.param("q");
    var url = { "all": "st/html/help/all/index.htm", "snda": "st/html/help/snda/index.htm", "outfit": "st/html/help/outfit/index.htm", "card": "st/html/help/card/index.htm", "life": "st/html/help/life/index.htm", "hobby": "st/html/help/hobby/index.htm" };
    var eq = "all", src = url[eq];
    if (!!url[go]) {
        eq = go;
        src = url[eq];
    } else if (!!go) {
        for (i in url) {
            if (go.indexOf(i) > -1) { eq = i; src = "st/html/help/" + go + "?q=" + q; break; };
        };
    };
    src = $("#J_url").val() + src;
    $("#J_go").attr("src", src);
    $("#J_tab").addClass("tab-" + eq);
    var crumb = $("#J_tab").find("a[class='tab-" + eq + "']").html();
    $("#J_crumb").html(crumb);
});
//在线客服
var snda_os_webrefer_ufg = {
    gm: 208,
    triggers: {
        floatwin: ["010101", "010102"],
        extend: [{ triggerid: "J_olservice", source: "010103" }, { triggerid: "J_olservice2", source: "010103"}]
    },
    t: "盛大商城-帮助中心",
    hidewidgetwindow: true
};
$("#J_olservice, #J_olservice2").attr("href", "javascript:void(0)");